package io.printff;

import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.nio.charset.Charset;

//打印流
public class Printff {
    public static void main(String[] args) {
        //创造打印流管道
       // try ( PrintStream ps=new  PrintStream("D:\\workspace\\basic-chapter\\src\\io\\packaging\\a.txt");
                    //字符输出流
                try (PrintWriter ps=new PrintWriter("D:\\workspace\\basic-chapter\\src\\io\\packaging\\a.txt");
                     //还可以指定输入编码格式
                     // try (PrintStream ps=new  PrintStream("D:\\workspace\\basic-chapter\\src\\io\\packaging\\a.txt", Charset.forName("GBK"));
        ){
            ps.println(97);
            ps.println('s');
            ps.println("爱你中国");
            ps.println(true);
            //内容打印到指定目录
            ps.write(97);//a
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
